package symbols;

import lexer.*;

public class Type extends Word {
    public int width = 0;
    public Type def;
    public Type(String s, int tag, Type def) {
	super(s, tag);
	this.def = def;
    }
    public Type(String s, int tag, int w) {
	super(s, tag);
	width = w;
    }
    public static final Type
	Int = new Type("integer", Tag.BASIC, 4),
	Char = new Type("char", Tag.BASIC, 1),
	Bool = new Type("bool", Tag.BASIC, 1);
    public static boolean numeric(Type p) {
	if (p == Type.Int || p == Type.Char)
	    return true;
	else return false;
    }
    public static Type max(Type p1, Type p2) {
	if (! numeric(p1) || ! numeric(p2))
	    return null;
	else if (p1 == Type.Int || p2 == Type.Int)
	    return Type.Int;
	else
	    return Type.Char;
    }
}
